package com.unhz.taigu.interface_controllers.register;

import com.unhz.generator.pojo.User;
import com.unhz.generator.utils.JsonResult;
import com.unhz.taigu.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: 廖永波
 * @Description:
 * @Date: Created in 上午 10:57 2018/3/6 0006
 * @Modified By: V1.0.0
 */
@RestController
@RequestMapping("/IRegister")
public class IRegisterController {

    @Autowired
    private UserService userService;

    /**
     * 注册
     * @param model
     * @param account
     * @param password
     * @param rPassword
     * @param code
     * @param rCode
     * @return
     */
   /* @RequestMapping("/register")
    public JsonResult redister(Model model,
                               @RequestParam(value= "account",required = false) String account,
                               @RequestParam(value= "password",required = false) String password,
                               @RequestParam(value= "rPassword",required = false) String rPassword,
                               @RequestParam(value= "code",required = false) String code,
                               @RequestParam(value= "rCode",required = false) String rCode){

        if(account.equals("")){
            return  JsonResult.failure("手机号为空！");
        }
        User u = userService.selectByUserPhone(account);
        if(u.getUserPhone().equals(account)){
            return JsonResult.success("手机号已被注册！");
        }
        if(password.equals("")){
            return  JsonResult.failure("密码为空！");
        }
        if(!password.equals(rPassword)){
            return  JsonResult.failure("密码输入不一致！");
        }
        if(!code.equals(rCode)){
            return  JsonResult.failure("验证码输入不正确！");
        }
        try{
            User user = new User();
            user.setUserPhone(account);
            user.setUserPassword(password);
            user.setCode(code);
            userService.insert(user);
        }catch (Exception e){
            e.printStackTrace();
        }

        return JsonResult.success("请求成功！");
    }*/
}
